%%  Fill setup struct
load curNum;    % current setup number
load setup setup;


C   = readMT3D('MT3D001.UCN');
setup(n).well    = setWellCout(setup(n).well,C,1);  % fill well object with concentration values

iTresholdReached = ceil(interp1(setup(n).well.Cout(setup(n).well.Q<0),find(setup(n).well.Q<0),0.9982)); % period index when treshold is reached. ceiled.
if ~isnan(iTresholdReached)
    setup(n).results.iTresh = iTresholdReached;
else
    iTresholdReached=find(setup(n).well.Q<0,1, 'first');
end
setup(n).results.tTresh     = setup(n).well.t(iTresholdReached); % find time where concentration of extracted water exceeds treshold
setup(n).results.CTresh     = setup(n).well.Cout(iTresholdReached);
setup(n).results.inj        = sum(setup(n).well.Q(setup(n).well.Q(1:iTresholdReached)>0));
setup(n).results.extr       = sum(setup(n).well.Q(setup(n).well.Q(1:iTresholdReached)<0));
setup(n).results.RE         = abs(setup(n).results.extr/setup(n).results.inj)*100;

setup(n).results.CsavedTresh= C(iTresholdReached).values;


save setup setup